package com.study.design.model.behaviorPattern.memento;

import org.junit.Test;

/**
* @Name: Client
* @Description: 备忘录模式测试类
* @Author: 李超	lc_jack@foxmail.com
* @CreateDate: 2017-2-15 下午10:44:45 
* @Version: V1.0
 */
public class Client {
	
	@Test
	public void memento() {
		CareTaker taker = new CareTaker() ;
		Emp emp = new Emp("张三", 21, 9876.35) ;
		System.out.println("第一次打印对象：" + emp);
		//备份当前对象的属性值
		taker.setMemento(emp.memento()) ;
		//修改对象的属性值
		emp.setEname("李四") ;
		emp.setAge(22) ;
		emp.setSalary(4444) ;
		System.out.println("第二次打印对象：" + emp);
		//恢复到备忘录对象保存的状态
		emp.recovery(taker.getMemento()) ;
		System.out.println("第三次打印对象：" + emp);
	}

}
